package shading;

import java.awt.Color;
import java.util.List;

import principal.Camera;
import principal.Luz;
import principal.Ponto;
import principal.Triangulo;

public class GourandShading {
	
	private Color corV1;
	private Color corV2;
	private Color corV3;
	
	public GourandShading(Luz luz, Triangulo triangulo, List<Ponto> pontos, Camera camera){
		Ponto p1 = pontos.get(0);
		Ponto p2 = pontos.get(1);
		Ponto p3 = pontos.get(2);
		this.corV1 = luz.calculaCorPhong(p1, p1.getNormal(), camera);
		this.corV2 = luz.calculaCorPhong(p2, p2.getNormal(), camera);
		this.corV3 = luz.calculaCorPhong(p3, p3.getNormal(), camera);
	}
	
	int getRGB(double alfa, double beta, Ponto pontoAtual)
	{
		Color cor;
		double gama = 1 - alfa - beta;
		
		cor = new Color((int)alfa * this.corV1.getRed() + (int)beta * this.corV2.getRed() + (int)gama * this.corV3.getRed(),
				(int)alfa * this.corV1.getGreen() + (int)beta * this.corV2.getGreen() + (int)gama * this.corV3.getGreen(),
				(int)alfa * this.corV1.getBlue() + (int)beta * this.corV2.getBlue() + (int)gama * this.corV3.getBlue());
	
		return cor.getRGB();
	}
}
